-
Notifications
You must be signed in to change notification settings - Fork 165
feat: middleware entrypoint #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: middleware entrypoint #241
Conversation
Co-authored-by: Fernando Otero <[email protected]>
Co-authored-by: Fernando Otero <[email protected]>
Co-authored-by: Fernando Otero <[email protected]>
| 📌 [`middleware_program_entrypoint!`](https://docs.rs/pinocchio/latest/pinocchio/macro.middleware_program_entrypoint.html) | ||
|
|
||
| The `middleware_program_entrypoint!` macro defines a dual entrypoint implementation consisting of a `hot` path which bypasses entrypoint deserialization, and a `cold` path with behaves like a regular pinocchio entrypoint that has undergone `program_entrypoint!` deserialization. This gives the user flexibility to implement extreme CU optimizations against the most critical paths in their proggram with the convenience of being able to fallback to a regular pinocchio program to manage the fail case and other instructions that do not require such optimizations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The `middleware_program_entrypoint!` macro defines a dual entrypoint implementation consisting of a `hot` path which bypasses entrypoint deserialization, and a `cold` path with behaves like a regular pinocchio entrypoint that has undergone `program_entrypoint!` deserialization. This gives the user flexibility to implement extreme CU optimizations against the most critical paths in their proggram with the convenience of being able to fallback to a regular pinocchio program to manage the fail case and other instructions that do not require such optimizations. | |
| The `middleware_program_entrypoint!` macro defines a dual entrypoint implementation consisting of a `hot` path which bypasses entrypoint deserialization, and a `cold` path which behaves like a regular pinocchio entrypoint that has undergone `program_entrypoint!` deserialization. This gives the user flexibility to implement extreme CU optimizations against the most critical paths in their program with the convenience of being able to fallback to a regular pinocchio program to manage the fail case and other instructions that do not require such optimizations. |
| nostd_panic_handler!(); | ||
| no_allocator!(); | ||
|
|
||
| middleware_program_entrypoint!(hot,cold); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| middleware_program_entrypoint!(hot,cold); | |
| middleware_program_entrypoint!(hot, cold); |
| /// nostd_panic_handler!(); | ||
| /// no_allocator!(); | ||
| /// | ||
| /// middleware_program_entrypoint!(hot,cold); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// middleware_program_entrypoint!(hot,cold); | |
| /// middleware_program_entrypoint!(hot, cold); |
| } | ||
| } | ||
| }; | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | |
| } | |
|
@febo I have added a feature flag called |
| unsafe { | ||
| core::arch::asm!( | ||
| "mov32 r0, {0}", | ||
| in(reg) $value | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a compile-time check that $value is a u32?
| unsafe { | |
| core::arch::asm!( | |
| "mov32 r0, {0}", | |
| in(reg) $value | |
| ); | |
| } | |
| unsafe { | |
| let v: u32 = $value; | |
| core::arch::asm!( | |
| "mov32 r0, {0}", | |
| in(reg) v | |
| ); | |
| } |
This PR implements the
middleware_entrypoint!macro. This macro enables users to define ahotpath that skips entrypoint deserialization for high priority instructions, with a fallback to acoldpath in the case that it does not returnSUCCESS.Attached is a simple code sample of how it can be used in practice, where an invocation with zero accounts will lead to the hot path, and anything else will fallback to the cold path: